/*
 * EmailNotification.java
 *
 * Created on Oct 12, 2007, 8:36:09 PM
 *
 * Copyright (c) October 14, 2007 by Dean Del Ponte
 * http://www.sourceseed.org
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published
 * by  the Free Software Foundation; either version 3 of the License or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this program; see the file COPYING.TXT.  If not, write to
 * the Free Software Foundation Inc., 59 Temple Place - Suite 330,
 * Boston, MA  02111-1307 USA
 */
package org.sourceseed.tools.backup.backThatThingUp;

import java.util.ArrayList;
import java.util.List;
import org.sourceseed.tools.backup.tasks.EmailTrigger;

/**
 * Contains list of who should receive email notifications, what will trigger these <br\>
 * notifications, and some basic information as to what should be included in the email
 * message.
 *
 * @author Dean Del Ponte
 */
public class EmailNotification {

    private List<String> emailAddresses;
    private EmailTrigger emailTrigger;
    private String from;
    private String subject;
    private String message;

    public EmailNotification() {
        this(new ArrayList<String>());
    }

    /**
     * 
     * @param emailAddresses List of recipient's email addresses
     */
    public EmailNotification(List<String> emailAddresses) {
        this.emailAddresses = emailAddresses;
        setEmailTrigger(EmailTrigger.ALL);
    }

    /**
     * 
     * @return EmailTrigger - contains information as to when emails should<br \>
     * be sent (i.e. on successful backup, on failure, both, etc.)
     */
    public EmailTrigger getEmailTrigger() {
        return emailTrigger;
    }

    /**
     * 
     * @param trigger
     */
    public void setEmailTrigger(EmailTrigger trigger) {
        this.emailTrigger = trigger;
    }

    /**
     * 
     * @return Email address which should be sent notifications for a particular emailTrigger
     */
    public List<String> getEmailAddresses() {
        return emailAddresses;
    }

    /**
     * 
     * @param emailAddresses List of recipient email addresses
     */
    public void setEmailAddresses(List<String> emailAddresses) {
        this.emailAddresses = emailAddresses;
    }

    /**
     * 
     * @return String which should appear in the "From" field of sent email
     */
    public String getFrom() {
        return from;
    }

    /**
     * 
     * @param from String which should appear in the "From" field of sent email
     */
    public void setFrom(String from) {
        this.from = from;
    }

    /**
     * 
     * @return Subject of email
     */
    public String getSubject() {
        return subject;
    }

    /**
     * 
     * @param subject Text to appear in subject line of sent email
     */
    public void setSubject(String subject) {
        this.subject = subject;
    }

    /**
     * 
     * @return Content included in body of sent email message
     */
    public String getMessage() {
        return message;
    }

    /**
     * 
     * @param message Content included in body of sent email message
     */
    public void setMessage(String message) {
        this.message = message.trim().toUpperCase();
    }

    /**
     * 
     * @return Returns true attributes of this class are not null, otherwise<br\>
     * returns false
     */
    public boolean isValid() {
        boolean valid = false;
        if (emailAddresses.size() > 0 && emailTrigger != null && from != null && message != null && subject != null) {
            valid = true;
        }
        return valid;
    }
}
